﻿<UserControl x:Class="Profit.Controls.RobotControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Profit.Controls" 
             xmlns:CoreResources="clr-namespace:Core.Resources;assembly=Profit.Core"
             xmlns:Resources="clr-namespace:Profit.Resources" 
             xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" 
             xmlns:Enums="clr-namespace:Core.Contracts.Enums;assembly=Profit.Core.Contracts" 
             xmlns:Globalization="clr-namespace:System.Globalization;assembly=mscorlib" xmlns:Services="clr-namespace:Profit.Services" mc:Ignorable="d" 
             d:DesignHeight="392" d:DesignWidth="764"
             UseLayoutRounding="True">
    <UserControl.Resources>
        <CollectionViewSource x:Key="slotsSource" Source="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Robot.Slots}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="SlotGroup"  />
            </CollectionViewSource.GroupDescriptions>
            <CollectionViewSource.SortDescriptions >
                <ComponentModel:SortDescription PropertyName="SlotGroup" Direction="Ascending"  />
                <ComponentModel:SortDescription PropertyName="SortOrder" Direction="Ascending"  />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
        <DataTemplate x:Key="GridViewColumnHeaderTemplate">
            <TextBlock Text="{Binding}" Margin="4" Width="Auto" MinWidth="20" />
        </DataTemplate>

        <ContextMenu x:Key="ModuleActionsContextMenu" Visibility="{Binding HasModule, Converter={StaticResource BooleanToVisibilityConverter}}" >
            
            <MenuItem 
                Header="{x:Static Resources:Messages.menu_remove_module}" 
                Click="MenuItemRemoveModuleClick" 
                CommandParameter="{Binding FittedModule}" />
            
            <MenuItem 
                Header="{x:Static Resources:Messages.label_ammunitions}" 
                VerticalContentAlignment="Center"
                Visibility="{Binding FittedModule.CanHaveAmmunitions, Converter={StaticResource BooleanToVisibilityConverter}}"
                ItemsSource="{Binding FittedModule.UsableAmmunitions}" 
                Click="MenuItemAmmunitionClick" 
                CommandParameter="{Binding FittedModule}">
                <MenuItem.Icon>
                    <Image MaxHeight="18" Source="{Binding FittedModule.UsableAmmunitionType, Converter={StaticResource AmmunitionTypeToImageSourceConverter}}" />
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
        
        <Style x:Key="TextAccumulatorUsageStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="Text" >
                <Setter.Value>
                    <MultiBinding StringFormat="{}{0:mm}:{0:ss} ({1} AP/s)" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                        <Binding Path="Robot.AccumulatorLifeSpan" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                        <Binding Path="Robot.AccumulatorRechargedPerSecond" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                    </MultiBinding>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Robot.IsAccumulatorStable, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
                    <Setter Property="Text">
                        <Setter.Value>
                            <MultiBinding StringFormat="{}Stable at {1:P0} ({0} AP/s)" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                                <Binding Path="Robot.AccumulatorRechargedPerSecond" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                                <Binding Path="Robot.AccumulatorStabilityPercentage" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                            </MultiBinding>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{Binding FittingDetailsColumnWidth, Source={x:Static Services:RegistryUserSettings.Default}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            <ColumnDefinition Width="{Binding RobotFeaturesColumnWidth, Source={x:Static Services:RegistryUserSettings.Default}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MaxWidth="300"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Grid.ColumnSpan="2" Margin="5,2,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="15"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="15"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="15"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <!--Cpu gauge-->
            <Image Grid.Column="0" Margin="2,0" Grid.RowSpan="2" Style="{StaticResource CpuImageStyle}" VerticalAlignment="Top"  Width="24" Height="24" ToolTip="{x:Static Resources:Messages.label_cpu_usage}" />
            <local:GaugeUsageControl Grid.Column="1" Grid.Row="0" ToolTip="{Binding Robot.CpuUsagePercentageString, RelativeSource={RelativeSource AncestorType=UserControl}}" NormalBrush="{StaticResource GreenLinearBrushKey}" OverflowBrush="{StaticResource RedLinearBrushKey}" Value="{Binding Robot.CpuUsagePercentage, RelativeSource={RelativeSource AncestorType=UserControl}}" Height="12" VerticalAlignment="Center" HorizontalAlignment="Left" Effect="{StaticResource DropShadowEffectLight}"/>
            <TextBlock Grid.Column="1" Grid.Row="1" Margin="2,0" HorizontalAlignment="Center" >
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} / {1} TF ({2})" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                        <Binding Path="Robot.TotalCpuUsage" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                        <Binding Path="Robot.CpuCapacity" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                        <Binding Path="Robot.AvailableCpu" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>

            <!--Reactor gauge-->
            <Image Grid.Column="3" Margin="2,0" Grid.RowSpan="2" Style="{StaticResource reactorImageStyle}" VerticalAlignment="Top" Width="24" Height="24" ToolTip="{x:Static Resources:Messages.label_reactor_usage}"/>
            <local:GaugeUsageControl Grid.Column="4" Grid.Row="0" ToolTip="{Binding Robot.ReactorUsagePercentageString, RelativeSource={RelativeSource AncestorType=UserControl}}" NormalBrush="{StaticResource GreenLinearBrushKey}" OverflowBrush="{StaticResource RedLinearBrushKey}"  Value="{Binding Robot.ReactorUsagePercentage, RelativeSource={RelativeSource AncestorType=UserControl}}" Height="12" VerticalAlignment="Center" HorizontalAlignment="Left" Effect="{StaticResource DropShadowEffectLight}"/>
            <TextBlock Grid.Column="4" Grid.Row="1" Margin="2,0" HorizontalAlignment="Center" >
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} / {1} RP ({2})" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                        <Binding Path="Robot.TotalReactorUsage" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                        <Binding Path="Robot.ReactorCapacity" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                        <Binding Path="Robot.AvailableReactor" RelativeSource="{RelativeSource AncestorType=UserControl}" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>

            <!--Accumulator stability-->
            <Image Grid.Column="6" Grid.RowSpan="2" Style="{StaticResource AccumulatorLifspanStyle}" VerticalAlignment="Top" Width="24" Height="24" ToolTip="{x:Static Resources:Messages.label_acc_stability}"/>
            <TextBlock Grid.Column="7" Grid.RowSpan="2" Style="{StaticResource TextAccumulatorUsageStyle}" Margin="5,0" VerticalAlignment="Center" HorizontalAlignment="Center" />

            <!-- Robot slots -->
            <local:SlotsControl Grid.Column="9" Grid.RowSpan="2" DataContext="{Binding Robot, RelativeSource={RelativeSource AncestorType=UserControl}}" />

        </Grid>

        <Border Grid.Column="0" Grid.Row="1" CornerRadius="2" Margin="5,1,5,5" Padding="1" BorderThickness="1" BorderBrush="{StaticResource GrayBlueBrushKey}" Background="{StaticResource WindowBackgroundBrush}">
            <ListView HorizontalAlignment="Stretch" BorderThickness="0" ItemsSource="{Binding Source={StaticResource slotsSource}}" SelectionMode="Single" MouseDoubleClick="ListViewMouseDoubleClick">
                <ListView.View>
                    <GridView AllowsColumnReorder="False">
                        <GridView.ColumnHeaderContainerStyle>
                            <Style TargetType="{x:Type GridViewColumnHeader}">
                                <Setter Property="Background" Value="{StaticResource DarkBrush}"/>
                                <Setter Property="BorderBrush" Value="{StaticResource DarkBrush}"/>
                                <Setter Property="BorderThickness" Value="0"/>
                                <Setter Property="Margin" Value="0"/>
                            </Style>
                        </GridView.ColumnHeaderContainerStyle>
                        <local:FixedGridViewColumn FixedWidth="32" >
                            <local:FixedGridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <ToggleButton Width="10" Height="14" Margin="0,1,0,0" Style="{StaticResource ModuleActivationButtonStyle}" IsChecked="{Binding FittedModule.IsActive, Mode=TwoWay}" Visibility="{Binding CanActivate, Converter={StaticResource BooleanToVisibilityConverter}}" >
                                        <ToggleButton.ToolTip>
                                            Activate/Deactivate the module
                                        </ToggleButton.ToolTip>
                                    </ToggleButton>
                                </DataTemplate>
                            </local:FixedGridViewColumn.CellTemplate>
                        </local:FixedGridViewColumn>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static Resources:Messages.label_name}">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto"/>
                                            <ColumnDefinition Width="1*" MinWidth="120"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        
                                        <Image 
                                            Grid.Column="0"
                                            Margin="2,0,0,0"
                                            Effect="{StaticResource DropShadowEffectLight}" 
                                            Source="{Binding FittedModule.TechnologyLevel, Converter={StaticResource ModuleTechnologyToImageConverter}}" />
                                        
                                        <TextBlock 
                                            Grid.Column="1"
                                            Margin="5,0"
                                            Text="{Binding FittedModule.Name}"
                                            TextTrimming="CharacterEllipsis" />
                                        
                                        <Image
                                            Grid.Column="2"
                                            MaxHeight="18"
                                            VerticalAlignment="Center"
                                            Visibility="{Binding FittedModule.HasAmmunitionsLoaded, Converter={StaticResource BooleanToVisibilityConverter}}"
                                            Source="{Binding FittedModule.Ammunitions, Converter={StaticResource AmmunitionToImageSourceConverter}}" >
                                            <Image.ToolTip>
                                                <ToolTip Style="{StaticResource featuresTooltipStyle}" Visibility="{Binding FittedModule.Ammunitions.HasFeatures, Converter={StaticResource BooleanToVisibilityConverter}}">
                                                    <StackPanel Orientation="Vertical">
                                                        
                                                        <HeaderedItemsControl
                                                            Header="{Binding FittedModule.Ammunitions}"
                                                            Style="{StaticResource AmmunitionFeaturesItemsControlStyle}"
                                                            ItemsSource="{Binding FittedModule.Ammunitions.Features}" />

                                                        <HeaderedItemsControl
                                                            Margin="0,3,0,0"
                                                            Visibility="{Binding FittedModule.Ammunitions.HasVisibleModifiers, Converter={StaticResource BooleanToVisibilityConverter}}"
                                                            Style="{StaticResource AmmunitionModifiersItemsControlStyle}"
                                                            ItemsSource="{Binding FittedModule.Ammunitions.Modifiers}" />
                                                        
                                                    </StackPanel>
                                                </ToolTip>
                                            </Image.ToolTip>
                                        </Image>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_unit_TF}" DisplayMemberBinding="{Binding FittedModule.CpuUsage, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_unit_RP}" DisplayMemberBinding="{Binding FittedModule.ReactorUsage, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_optimal}" DisplayMemberBinding="{Binding FittedModule.OptimalRange, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_falloff}" DisplayMemberBinding="{Binding FittedModule.Falloff, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_unit_AP}" DisplayMemberBinding="{Binding FittedModule.AccumulatorUsage, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_cycle_time}" DisplayMemberBinding="{Binding FittedModule.CycleTime, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                        <GridViewColumn HeaderTemplate="{StaticResource GridViewColumnHeaderTemplate}" Header="{x:Static CoreResources:Traduction.label_unit_ap_per_second}" DisplayMemberBinding="{Binding FittedModule.AccumulatorUsagePerSecond, ConverterCulture={x:Static Globalization:CultureInfo.CurrentCulture}}"/>
                    </GridView>
                </ListView.View>
                <ListView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.ContainerStyle>
                            <Style TargetType="{x:Type GroupItem}">
                                <Setter Property="Margin" Value="0"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type GroupItem}">
                                            <Border>
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition Height="Auto"/>
                                                    </Grid.RowDefinitions>
                                                    <Border Grid.Row="0" BorderBrush="{StaticResource HorizontalNormalBrush}" CornerRadius="0" BorderThickness="0,0,0,2" Margin="4,2">
                                                        <TextBlock Margin="5,0,0,0" FontWeight="Bold" >
                                                            <TextBlock.Text>
                                                                <MultiBinding StringFormat="{}{0} ({1})" ConverterCulture="{x:Static Globalization:CultureInfo.CurrentCulture}">
                                                                    <Binding Path="Name" Mode="OneTime" />
                                                                    <Binding Path="ItemCount" Mode="OneTime" />
                                                                </MultiBinding>
                                                            </TextBlock.Text>
                                                        </TextBlock>
                                                    </Border>
                                                    <ItemsPresenter Grid.Row="1" />
                                                </Grid>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </GroupStyle.ContainerStyle>
                    </GroupStyle>
                </ListView.GroupStyle>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="ToolTip">
                            <Setter.Value>
                                <ToolTip Style="{StaticResource featuresTooltipStyle}" Visibility="{Binding HasModule, Converter={StaticResource BooleanToVisibilityConverter}}">
                                    <StackPanel Orientation="Vertical">

                                        <HeaderedItemsControl
                                            x:Name="ModuleFeaturesPanel"
                                            Style="{StaticResource ModuleFeaturesItemsControlStyle}"
                                            Header="{Binding FittedModule}" 
                                            ItemsSource="{Binding FittedModule.Features}" />

                                        <HeaderedItemsControl
                                            x:Name="ModuleModifiersPanel"
                                            Visibility="{Binding FittedModule.HasVisibleModifiers, Converter={StaticResource BooleanToVisibilityConverter}}"
                                            Margin="0,3,0,0"
                                            Style="{StaticResource ModuleModifiersItemsControlStyle}"
                                            ItemsSource="{Binding FittedModule.Modifiers}" />

                                    </StackPanel>
                                </ToolTip>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="OverridesDefaultStyle" Value="True"/>
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <Border x:Name="Border" CornerRadius="2" Margin="2,1" Padding="2" Background="{StaticResource AlphaWhiteBrushKey}" BorderThickness="1" BorderBrush="{x:Null}" >
                                        <Grid>
                                            <StackPanel x:Name="SlotTypesImages"  Orientation="Horizontal" Visibility="Collapsed" >
                                                <Image x:Name="imgSlotTypeIndus" Visibility="{Binding Converter={StaticResource SlotFittableTypesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotTypesEnum.Industrial}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeIndustry_15.png" ToolTip="{x:Static Resources:Messages.label_slot_type_industry}"/>
                                                <Image x:Name="imgSlotTypeTurret" Visibility="{Binding Converter={StaticResource SlotFittableTypesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotTypesEnum.Turret}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeTurret_15.png" ToolTip="{x:Static Resources:Messages.label_slot_type_turret}"/>
                                                <Image x:Name="imgSlotTypeMissile" Visibility="{Binding Converter={StaticResource SlotFittableTypesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotTypesEnum.Missile}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeMissile_15.png" ToolTip="{x:Static Resources:Messages.label_slot_type_missile}"/>
                                                <Image x:Name="imgSlotTypeMisc" Visibility="{Binding Converter={StaticResource SlotFittableTypesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotTypesEnum.Misc}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeMisc_15.png" ToolTip="{x:Static Resources:Messages.label_slot_type_misc}"/>
                                                <Image x:Name="imgSlotSizeSmall" Visibility="{Binding Converter={StaticResource SlotFittableSizesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SizesEnum.Small}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotSizeSmall_15.png" ToolTip="{x:Static Resources:Messages.label_slot_size_small}"/>
                                                <Image x:Name="imgSlotSizeMedium" Visibility="{Binding Converter={StaticResource SlotFittableSizesEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SizesEnum.Medium}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotSizeMedium_15.png" ToolTip="{x:Static Resources:Messages.label_slot_size_medium}"/>
                                                <Image x:Name="imgSlotGroupHead" Visibility="{Binding Converter={StaticResource SlotFittableGroupEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotGroupsEnum.Head}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeHead_15.png" ToolTip="{x:Static Resources:Messages.label_slot_group_head}"/>
                                                <Image x:Name="imgSlotGroupLegs" Visibility="{Binding Converter={StaticResource SlotFittableGroupEnumToVisibilityConverter}, ConverterParameter={x:Static Enums:SlotGroupsEnum.Legs}}" Style="{StaticResource slotImageStyle}" Source="/Profit;component/Resources/Icons/slotTypeLegs_15.png" ToolTip="{x:Static Resources:Messages.label_slot_group_legs}"/>
                                            </StackPanel>
                                            <GridViewRowPresenter Content="{TemplateBinding Content}" Columns="{TemplateBinding GridView.ColumnCollection}" ContextMenu="{StaticResource ModuleActionsContextMenu}"  />
                                        </Grid>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <DataTrigger Binding="{Binding HasModule}" Value="False">
                                            <Setter TargetName="SlotTypesImages" Property="Visibility" Value="Visible"/>
                                            <Setter TargetName="Border" Property="Background" Value="{StaticResource LightBlueHorizontalBrushKey}"/>
                                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource WhiteBrushKey}"/>
                                        </DataTrigger>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="IsSelected" Value="True" />
                                        </Trigger>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter TargetName="Border" Property="Background" Value="{StaticResource AlphaBlueLinearBrushKey}"/>
                                            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource LightBlueBrushKey}"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </Border>
        <GridSplitter Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Background="{StaticResource TransparentBrushKey}" Width="5" Margin="1,0,0,5" />
        <Border Grid.Column="1" Grid.Row="1" Margin="0,0,0,5" >
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <HeaderedItemsControl 
                        Grid.Row="0" 
                        Margin="0,0,0,0"
                        Header="{x:Static Enums:FeatureGroupsEnum.Engine}"
                        Style="{StaticResource RobotFeaturesItemsControlStyle}"
                        ItemsSource="{Binding Robot.EngineFeatures, RelativeSource={RelativeSource AncestorType=UserControl}}" >
                    </HeaderedItemsControl>

                    <HeaderedItemsControl 
                        Grid.Row="1" 
                        Margin="0,2,0,0"
                        Header="{x:Static Enums:FeatureGroupsEnum.Defence}"
                        Style="{StaticResource RobotFeaturesItemsControlStyle}"
                        ItemsSource="{Binding Robot.DefenceFeatures, RelativeSource={RelativeSource AncestorType=UserControl}}" >
                    </HeaderedItemsControl>

                    <HeaderedItemsControl 
                        Grid.Row="2" 
                        Margin="0,2,0,0"
                        Header="{x:Static Enums:FeatureGroupsEnum.TargetingEquipment}"
                        Style="{StaticResource RobotFeaturesItemsControlStyle}"
                        ItemsSource="{Binding Robot.TargetingEquipmentFeatures, RelativeSource={RelativeSource AncestorType=UserControl}}" >
                    </HeaderedItemsControl>

                    <HeaderedItemsControl 
                        Grid.Row="3" 
                        Margin="0,2,0,0"
                        Header="{x:Static Enums:FeatureGroupsEnum.General}"
                        Style="{StaticResource RobotFeaturesItemsControlStyle}"
                        ItemsSource="{Binding Robot.GeneralFeatures, RelativeSource={RelativeSource AncestorType=UserControl}}" >
                    </HeaderedItemsControl>
                </Grid>
            </ScrollViewer>
        </Border>
    </Grid>
</UserControl>
